package com.easy.controller;

import com.easy.common.api.CommonResult;
import com.easy.domain.User;
import com.easy.service.NoteService;
import com.easy.service.SessionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @author 风亦未止
 * @date 2021/9/20 14:28
 */
@Api(tags = "测试")
@RestController
@RequestMapping("demo")
public class DemoController {
    @Autowired
    private HttpSession httpSession;

    @Autowired
    private NoteService noteService;

    @Autowired
    private SessionService sessionService;

    @GetMapping("/get/{type}")
    @ApiOperation(value = "测试")
    public CommonResult get(@PathVariable("type") @ApiParam(value = "类型") int type){
        return null;
//        return noteService.getAllList(type);
    }

    @GetMapping("/getSession")
    @ApiOperation(value = "session测试")
    public CommonResult getSession(){
        String sessionId = httpSession.getId();
        User user = (User) sessionService.getSession(sessionId);
        return CommonResult.success(user);
    }

}
